package com.mango.demo.threadcase3;

import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author：wlz
 * @Package：threadcase3
 * @Project：mythread
 * @name：Mycallable
 * @Date：2023/3/28 20:30
 * @Filename：Mycallable
 */
public class Mycallable implements Callable<Integer> {
    private static ConcurrentHashMap<Object,Object> currentHashmap = new ConcurrentHashMap();
    @Override
    public Integer call() {
//        System.out.println(Thread.currentThread().getName());
//        // 求1-100之间的和
//        int sum = 0;
//        for (int i = 0; i < 100; i++) {
//            sum +=i;
//        }
////        System.out.println(Thread.currentThread().getName());
//        return sum;
        String a = "11";
        Object o = currentHashmap.putIfAbsent(a, 1);
        if (o!=null){
                return 0;
            }
            System.out.println("test......");
            //currentHashmap.remove(a);
            return 1;

    }
}
